package com.zy.config;

import com.zy.interceptor.DemoInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @auther zzyy
 * @create 2025-01-03 13:41
 */
@Configuration
public class WebConfig implements WebMvcConfigurer
{
    @Resource
    private DemoInterceptor demoInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        System.out.println("拦截器注册。开始接受http请求");
        registry.addInterceptor(demoInterceptor).addPathPatterns("/**"); // 拦截所有接口
    }
}
